89c3d0
@@ -71,7 +71,19 @@
public class CronSequenceGenerator {
 
 
 	/**
-	 * Construct a {@link CronSequenceGenerator} from the pattern provided.
+	 * Construct a {@link CronSequenceGenerator} from the pattern provided,
+	 * using the default {@link TimeZone}.
+	 * @param expression a space-separated list of time fields
+	 * @throws IllegalArgumentException if the pattern cannot be parsed
+	 * @see java.util.TimeZone#getDefault()
+	 */
+	public CronSequenceGenerator(String expression) {
+		this(expression, TimeZone.getDefault());
+	}
+
+	/**
+	 * Construct a {@link CronSequenceGenerator} from the pattern provided,
+	 * using the specified {@link TimeZone}.
 	 * @param expression a space-separated list of time fields
 	 * @param timeZone the TimeZone to use for generated trigger times
 	 * @throws IllegalArgumentException if the pattern cannot be parsed
@@ -114,12 +126,17 @@
public class CronSequenceGenerator {
 		calendar.setTimeZone(this.timeZone);
 		calendar.setTime(date);
 
-		// Truncate to the next whole second
-		calendar.add(Calendar.SECOND, 1);
+		// First, just reset the milliseconds and try to calculate from there...
 		calendar.set(Calendar.MILLISECOND, 0);
-
+		long originalTimestamp = calendar.getTimeInMillis();
 		doNext(calendar, calendar.get(Calendar.YEAR));
 
+		if (calendar.getTimeInMillis() == originalTimestamp) {
+			// We arrived at the original timestamp - round up to the next whole second and try again...
+			calendar.add(Calendar.SECOND, 1);
+			doNext(calendar, calendar.get(Calendar.YEAR));
+		}
+
 		return calendar.getTime();
 	}
 
